﻿<%@ Page MasterPageFile="~/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="ProductEdit.aspx.cs" Inherits="RabbitManage.UI.ProductEdit" %>

<%--<asp:Content runat="server" ID="NaviContent" ContentPlaceHolderID="FeaturedContent">
    <ul id="menu">
        <li><a href="/UI/ShopDetail.aspx">商家信息</a></li>
        <li><a href="/UI/ProductList.aspx">产品列表</a></li>
        <li><a href="/UI/ProductAdd.aspx">产品上架</a></li>
    </ul>
</asp:Content>--%>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    
    <% if (product == null)
       { %>
          什么也没有找到   ╮(╯_╰)╭ 
    <% }
       else
       { %>
    
    <form id="form1" action="../Action/ProductAdd.aspx?id=<%= product.Id %>" method="POST">

        <h3>修改</h3>
    
    <script type="text/javascript">
        form1.onsubmit = function (e) {
            // stop the regular form submission
            e.preventDefault();

            // collect the form data while iterating over the inputs
            var data = {};
            for (var i = 0, ii = form1.length; i < ii; ++i) {
                var input = form1[i];
                if (input.name) {
                    data[input.name] = input.value;
                }
            }

            // construct an HTTP request
            var xhr = new XMLHttpRequest();
            xhr.open(form1.method, form1.action, true);
            xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

            // send the collected data as JSON
            xhr.send(JSON.stringify(data));

            xhr.onloadend = function () {
                // done
                if (xhr.responseText == "true") {
                    window.location = "ProductList.aspx";
                } else {
                    alert(xhr.responseText);
                }
            };
        };
    </script>
    <script type="text/javascript" src="../Scripts/calendar.js"></script>
    
    <script type="text/javascript" src="../Scripts/WdatePicker.js"></script>
    

    <table>
        <tr>
            <td>名称:</td>
            <td>
                <input type="text" id="inputName" name="Name" value="<%= product.Name %>"/>
            </td>
        </tr>
        
        <tr>
            <td>单价(元):</td>
            <td>
                <input type="text" id="inputPricePerUnit" name="PricePerUnit" value="<%= product.PricePerUnit %>"/>
            </td>
        </tr>
        
        <tr>
            <td>净重(kg):</td>
            <td>
                <input type="text" id="inputNetWeight" name="NetWeight" value="<%= product.NetWeight %>"/>
            </td>
        </tr>
        
        <tr>
            <td>毛重(kg):</td>
            <td>
                <input type="text" id="inputGrossWeight" name="GrossWeight" value="<%= product.GrossWeight %>"/>
            </td>
        </tr>
        
        <tr>
            <td>生产日期:</td>
            <td>
                <input readonly="readonly" type="text" class="Wdate" id="inputProductionDate" name="ProductionDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  value="<%= product.ProductionDate %>" />
            </td>
        </tr>
        
        <tr>
            <td>库存:</td>
            <td>
                <input type="text" id="inputQuantity" name="Quantity" value="<%= product.Quantity %>"/>
            </td>
        </tr>
        
        <tr>
            <td>页面主图:</td>
            <td>
                <input type="text" name="MainImage" value="<%=product.MainImage %>"/>
            </td>
        </tr>
        
        <tr>
            <td>页面主标题:</td>
            <td>
                <input type="text"  name="Title" value="<%=product.Title %>"/>
            </td>
        </tr>
        
        <tr>
            <td>页面二级标题:</td>
            <td>
                <input type="text"  name="SubTitle" value="<%=product.SubTitle %>"/>
            </td>
        </tr>

        <tr>
            <td>描述:</td>
        </tr>
    </table>
        
        <textarea id="inputDescription" name="description" style="height: 200px;"><%= product.Description %></textarea>
        <br/>
    
        <input type="submit" value="提交" />

    </form>
  
    <% } %>
    


</asp:Content>